package com.societyGames.flashForms
{
import com.societyGames.system.EventObject;

import flash.events.Event;
import flash.text.TextField;

/*TextField that raises change event when it sizes.*/
public class DynamicTextField extends TextField implements IChangeSize
{
  private var _sizeChangedEventObject:EventObject;
  //private var _lastWidth:Number;
  //private var _lastHeight:Number;

  public function DynamicTextField()
  {
    this._sizeChangedEventObject = new EventObject(this, "SIZE_CHANGED", Event);
  }

  public function get sizeChangedEventObject():EventObject
  {
    return this._sizeChangedEventObject;
  }

  public override function set text(value:String):void
  {
    super.text = value;
    reactToPossibleSizeChange();
  }

  public override function set htmlText(value:String):void
  {
    super.htmlText = value;
    reactToPossibleSizeChange();
  }

  private function reactToPossibleSizeChange():void
  {
    /*if (this._lastWidth != this.width || this._lastHeight != this.height)
    {
      this._lastWidth = this.width;
      this._lastHeight = this.height;*/
      this.sizeChangedEventObject.dispatchEvent();
    //}
  }
}
}